//
//  BLWeatherDetailsButton.m
//  weather
//
//  Created by 大L君的无敌战舰 on 16/4/11.
//  Copyright © 2016年 bigL.com. All rights reserved.
//


#import "BLButtonForWeatherFirstView.h"

@interface BLButtonForWeatherFirstView ()
/* 天气描述 */
@property (strong, nonatomic) UILabel * describe;
/* 日期描述 :今天 | 明天 */
@property (strong, nonatomic) UILabel * date;
/* 空气质量图标 */
@property (strong, nonatomic) UIImageView *airQuality;
/* 气温描述 */
@property (strong, nonatomic) UILabel * temperature;
/* 预报图标 */
@property (strong, nonatomic) UIImageView *forecastImageView;

@end

@implementation BLButtonForWeatherFirstView


- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        //加载子控件
        [self setChildView];
        //加载数据
        [self loadData];
    }
    return self;
}



//加载子控件
-(void)setChildView
{
    /* 天气描述 */
    UILabel * describe = [[UILabel alloc]init];
    describe.font = TextSmallSize;
    self.describe = describe;
    [self addSubview:describe];
    //约束
    [describe mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).with.offset(5);
        make.bottom.equalTo(self).with.offset(0);
        make.width.equalTo(self.mas_width).multipliedBy(0.5);
        make.height.equalTo(self.mas_height).multipliedBy(0.5);
    }];
    
    
    /* 日期描述 :今天 | 明天 */
    UILabel * date = [[UILabel alloc]init];
    date.font = TextSmallSize;
    self.date = date;
    [self addSubview:date];
    //约束
    [date mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).with.offset(5);
        make.top.equalTo(self).with.offset(0);
        make.width.equalTo(self.mas_width).multipliedBy(0.3);
        make.height.equalTo(self.mas_height).multipliedBy(0.5);
    }];
    
    /* 空气质量图标 */
    UIImageView * airQuality = [[UIImageView alloc]init];
    self.airQuality = airQuality;
    [self addSubview:airQuality];
    //约束
    [airQuality mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.date.mas_right).with.offset(0);
        make.top.equalTo(self).with.offset(0);
        make.width.equalTo(self.mas_width).multipliedBy(0.3);
        make.height.equalTo(self.mas_height).multipliedBy(0.5);
    }];
    
    
    /* 气温描述 */
    UILabel * temperature = [[UILabel alloc]init];
    temperature.font = TextSmallSize;
    self.temperature = temperature;
    [self addSubview:temperature];
    //约束
    [temperature mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self).with.offset(0);
        make.top.equalTo(self).with.offset(0);
        make.height.equalTo(self.mas_height).multipliedBy(0.5);
    }];
    
    
    /* 预报图标 */
    UIImageView * forecastImageView = [[UIImageView alloc]init];
    self.forecastImageView = forecastImageView;
    [self addSubview:forecastImageView];
    //约束
    [forecastImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self).with.offset(0);
        make.bottom.equalTo(self).with.offset(0);
        make.width.equalTo(self.mas_width).multipliedBy(0.5);
        make.height.equalTo(self.mas_height).multipliedBy(0.5);
    }];
}


//加载数据
- (void)loadData
{
    self.describe.text    = @"阴";
    self.date.text        = @"今天";
    self.temperature.text = @"最低21°C";
    
    self.describe.textColor    = [UIColor whiteColor];
    self.date.textColor        = [UIColor whiteColor];
    self.temperature.textColor = [UIColor whiteColor];
    
    
    //    self.describe.backgroundColor = BLRandomColor(1);
    //    self.date.backgroundColor     = BLRandomColor(1);
    //    self.temperature.backgroundColor = BLRandomColor(1);
    
    
    self.airQuality.backgroundColor = BLRandomColor(2);
    self.forecastImageView.backgroundColor = BLRandomColor(2);
    
    
}
@end
